<template>  
    <view class="all-view uni-bg-gray">  
        <map latitude="22.619613565184746" longitude="113.05628099361725" scale="16" id="myMap" style="width:100%;height:300px;" :markers="convers" @regionchange="getCenterLocation">  
        </map>  
		<!-- <button v-on:click="getCenterLocation">132134</button> -->
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
				mapCtx:'',
				convers:[
					{
						title:'目标定位',
						latitude:22.619613565184746,
						longitude:113.05628099361725
					}
				]
            };  
        },  
        computed: {  
        },  
        onReady(options) {
			this.mapCtx = uni.createMapContext('myMap')
            
        },  
        onLoad(options) {  
            
        },  
        methods: {  
			
			 getCenterLocation() {
				 let that = this;
			    //获取当前地图中心的经纬度 
			    this.mapCtx.getCenterLocation({
			      success(res) {
			        console.log(res.longitude)
			        //获取的经度
			         console.log(res.latitude)
			        //获取的纬度 //使用支付宝内置地图查看位置，可以实现导航和打车等操作 
					that.convers = [];
					that.convers.push({
						longitude:res.longitude,
						latitude:res.latitude
					})
			      }
			    })
			  },
			  moveToLocation() {
			    //移动地图中心的位置为当前位置，实现定位
			    this.mapCtx.moveToLocation()
			  }
        }  
    }  
</script>  

<style>  

</style>  